import { observer } from 'mobx-react'
import React from 'react'
import store from '../../store'
import styles from './index.module.less'
import { getQuestionByType } from '@/pages/archives/components'

const Questionnaire = () => {
    const { fileDetail } = store || {}

    return (
        <div className={styles.questionnaire}>
            {fileDetail.detail?.items
                ?.filter((item: any) => item.type !== 7)
                .map((item: any, idx: number) => {
                    const { type, code, scheme } = item
                    const Comp = getQuestionByType(type)
                    if (!Comp) {
                        return null
                    }
                    return <Comp key={code} scheme={scheme} answers={fileDetail.detail?.originalData[code]} idx={idx + 1} />
                })}
        </div>
    )
}

export default observer(Questionnaire)
